
const data = {
	contract: '',
	AskPrice: 0,
	AskVolume: 0,
	BidPrice: 0,
	BidVolume: 0,
	LastPrice: 0,
	Time: Date.now()
}

async function main(market, base, quote) {

	const url = `https://www.cointiger.com/exchange/api/public/market/detail`
	try {
		const {statusCode, body} = await Request.getAsync(url, {timeout: config.timeout, json: true})
		// console.log(url, statusCode, body)

		if (statusCode == 200 ) {
			for (let key in body) {
				if (key === `${base.toUpperCase()}${quote.toUpperCase()}`) {
					const Data = body[key]
					data[0] = Number(Data.last)
					data[1] = Number(Data.lowestAsk)
					data[2] = Number(Data.highestBid)
					Cache.hmset('data', data)
				}
			}
		}
	} catch (error) {
		LOG([market, error.code || error.message || error])
	}

	await Promise.delay(config.timeout * 0.5)
	main(market, base, quote)
}

module.exports = main
